//
//  BrandDisplayTableViewCell.m
//  Blank
//
//  Created by whg－54 on 15/9/24.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "BrandDisplayTableViewCell.h"
#import "BrandDisplayModel.h"
#import <UIImageView+WebCache.h>
#import <Masonry.h>
@interface BrandDisplayTableViewCell ()
@property (nonatomic , strong)UIImageView *picView;

@property (nonatomic , strong)UIImageView *lineView;
@property (nonatomic , strong)UILabel *enameLabel;

@end
@implementation BrandDisplayTableViewCell

- (void)awakeFromNib {
    // Initialization code
}
#pragma mark - 重写初始化方法
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    self.picView = [[UIImageView alloc]init];
    self.brandLabel = [[UILabel alloc]init];
    self.lineView = [[UIImageView alloc]init];
    self.enameLabel = [[UILabel alloc]init];
    
    [self.contentView addSubview:self.enameLabel];
    [self.contentView addSubview:self.picView];
    [self.contentView addSubview:self.brandLabel];
    [self.contentView addSubview:self.lineView];
    
    
    return self;
}

#pragma mark - 重写model类的初始化方法
- (void) setModel:(BrandDisplayModel *)model
{
    [self.picView sd_setImageWithURL:[NSURL URLWithString:model.img]placeholderImage:[UIImage imageNamed:@"zhanwei"]];
    self.brandLabel.text = model.name;
    self.enameLabel.text = model.ename;
    self.brandid = model.brandid;
}

#pragma mark - 布局控件
- (void) layoutSubviews
{
   // self.picView.frame = CGRectMake(10*Windth, 5*Height, 100*Windth, 70*Height);
//    self.picView.backgroundColor = [UIColor greenColor];
//    
//    self.brandLabel.backgroundColor = [UIColor redColor];
//    
//    self.enameLabel.backgroundColor = [UIColor yellowColor];
    
    self.lineView.backgroundColor = [UIColor colorWithWhite:0.902 alpha:1.000];
    
    [self.picView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.edges.equalTo(self.contentView).with.insets(UIEdgeInsetsMake(5*Height, 10*Windth, 5*Height, 265*Windth));
        
    }];
    
    [self.brandLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.contentView).with.insets(UIEdgeInsetsMake(10*Height , 150*Windth , 40*Height , 65*Windth));
    }];
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.edges.equalTo(self.contentView).with.insets(UIEdgeInsetsMake(79*Height, 0, 0, 0));
        
    }];
    
    [self.enameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.contentView).with.insets(UIEdgeInsetsMake(40*Height, 150*Windth, 10*Height, 65*Windth));
    }];
    
    /**
     *  夜间模式
     */
    if ([NightModel getColorModel]) {
        self.brandLabel.backgroundColor = [UIColor grayColor];
        self.brandLabel.textColor = [UIColor whiteColor];
        self.enameLabel.backgroundColor = [UIColor grayColor];
        self.enameLabel.textColor = [UIColor whiteColor];
        self.contentView.backgroundColor = [UIColor grayColor];
       
    }
    else{
        
        self.brandLabel.backgroundColor = [UIColor whiteColor];
        self.brandLabel.textColor = [UIColor blackColor];
        self.enameLabel.backgroundColor = [UIColor whiteColor];
        self.enameLabel.textColor = [UIColor blackColor];
        self.contentView.backgroundColor = [UIColor whiteColor];

       
        
        
        
    }
    
    
    
    
    
    
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
